<template>
  <div class="app-container">
    <el-form ref="form" :model="form" :rules="rules" label-width="80px" style="width: 1000px;">
      <el-row>
        <el-col :span="24">
          <el-form-item label="注：">
            <span>平面图最大分辨率为338*200，超出恐造成变形！</span>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="图片a">
            <uploadImage v-model="form.dta"/>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="图片b">
            <uploadImage v-model="form.dtb"/>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="图片c">
            <uploadImage v-model="form.dtc"/>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="图片d">
            <uploadImage v-model="form.dtd"/>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="图片e">
            <uploadImage v-model="form.dte"/>
          </el-form-item>
        </el-col>

      </el-row>

    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm">确 定</el-button>
    </div>
  </div>
</template>

<script>
  import { getSysConfig, updateSysConfig } from "@/api/basic/sysConfig";
  import UploadImage from '@/components/UploadImage';

export default {
  components: {
    UploadImage
  },
  data() {
    return {
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.handleUpdate();
  },
  methods: {
// 表单重置
    reset() {
      this.form = {
        id: null,
        dta: null,
        dtb: null,
        dtc: null,
        dtd: null,
        dte: null,
      };
      this.resetForm("form");
    },
    /** 修改按钮操作 */
    handleUpdate() {
      this.reset();
      getSysConfig().then(response => {
        this.form = response.data;
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          updateSysConfig(this.form).then(response => {
            this.msgSuccess("修改成功");
          });
        }
      });
    },
  }
};
</script>
